/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.biz.modular.congress.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.congress.entity.BizCongress;
import vip.xiaonuo.biz.modular.congress.param.BizCongressAddParam;
import vip.xiaonuo.biz.modular.congress.param.BizCongressEditParam;
import vip.xiaonuo.biz.modular.congress.param.BizCongressIdParam;
import vip.xiaonuo.biz.modular.congress.param.BizCongressPageParam;
import vip.xiaonuo.biz.modular.congress.service.BizCongressService;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * 职工代表大会控制器
 *
 * @author 薛守立
 * @date  2024/07/11 15:07
 */
@Tag(name = "职工代表大会控制器")
@RestController
@Validated
public class BizCongressController {

    @Resource
    private BizCongressService bizCongressService;

    /**
     * 获取职工代表大会分页
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "获取职工代表大会分页")
    @SaCheckPermission("/biz/congress/page")
    @GetMapping("/biz/congress/page")
    public CommonResult<Page<BizCongress>> page(BizCongressPageParam bizCongressPageParam) {
        return CommonResult.data(bizCongressService.page(bizCongressPageParam));
    }

    /**
     * 添加职工代表大会
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "添加职工代表大会")
    @CommonLog("添加职工代表大会")
    @SaCheckPermission("/biz/congress/add")
    @PostMapping("/biz/congress/add")
    public CommonResult<String> add(@RequestBody @Valid BizCongressAddParam bizCongressAddParam) {
        bizCongressService.add(bizCongressAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑职工代表大会
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "编辑职工代表大会")
    @CommonLog("编辑职工代表大会")
    @SaCheckPermission("/biz/congress/edit")
    @PostMapping("/biz/congress/edit")
    public CommonResult<String> edit(@RequestBody @Valid BizCongressEditParam bizCongressEditParam) {
        bizCongressService.edit(bizCongressEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除职工代表大会
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "删除职工代表大会")
    @CommonLog("删除职工代表大会")
    @SaCheckPermission("/biz/congress/delete")
    @PostMapping("/biz/congress/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                       List<BizCongressIdParam> bizCongressIdParamList) {
        bizCongressService.delete(bizCongressIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取职工代表大会详情
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "获取职工代表大会详情")
    @SaCheckPermission("/biz/congress/detail")
    @GetMapping("/biz/congress/detail")
    public CommonResult<BizCongress> detail(@Valid BizCongressIdParam bizCongressIdParam) {
        return CommonResult.data(bizCongressService.detail(bizCongressIdParam));
    }

    /**
     * 获取职工代表大会列表
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "获取职工代表大会列表")
    @GetMapping("/biz/congress/list")
    public CommonResult<List<BizCongress>> list() {
        return CommonResult.data(bizCongressService.getList());
    }

    /**
     * 条件查询职代会列表
     *
     * @author 薛守立
     * @date  2024/07/11 15:07
     */
    @Operation(summary = "条件查询职代会列表")
    @SaCheckPermission("/biz/congress/listByCon")
    @GetMapping("/biz/congress/listByCon")
    public CommonResult<List<BizCongress>> listByCon(@Valid BizCongressIdParam bizCongressIdParam) {
        return CommonResult.data(bizCongressService.getListByCon(bizCongressIdParam));
    }

}
